const {mysql} = require('../qcloud')

async function brandDetail (ctx) {
    const {id} = ctx.request.query

    const detail = await mysql('nideshop_brand').where({
        id
    }).select()

    ctx.state.data = {
        detail: detail[0]
    }
}

async function goodsList (ctx) {
    const {brandId, pageSize, page} = ctx.request.query

    const goodsList = await mysql('nideshop_goods')
        .where({
            'brand_id': brandId
        })
        .limit(pageSize)
        .offset(Number(page) * pageSize)
        .select()

    ctx.state.data = {
        goodsList
    }
}

module.exports = {
    brandDetail,
    goodsList
}
